import React from 'react';
import styled from 'styled-components';

const Container = styled.div`
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #fff;
  // border-radius: 16px;
  overflow: hidden;

  .dark & {
    background: #18181B;
  }
`;

const Content = styled.div`
  flex: 1;
  iframe {
    width: 100%;
    height: 100%;
    border: none;
  }
`;

interface FragmentWebProps {
  result: any;
  onClose?: () => void;
}

export function FragmentRfp({ result, onClose,html }: FragmentWebProps) {
  const [iframeKey, setIframeKey] = React.useState(0);

  const refreshIframe = () => {
    setIframeKey((prevKey) => prevKey + 1);
  };

  window.refreshIframe = refreshIframe

  return (
    <Container>
      <Content>
        <iframe key={iframeKey}  srcdoc={html}/>
      </Content>
    </Container>
  );
}
